# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor: Xu Fasheng <fasheng.xu[AT]gmail.com>

pkgname=deepin-desktop-base
pkgver=2022.07.26
pkgrel=2
epoch=2
pkgdesc='Base component for Deepin'
arch=('any')
url="https://github.com/linuxdeepin/deepin-desktop-base"
license=('GPL3')
groups=('deepin')
source=("$pkgname-$pkgver.tar.gz::https://github.com/linuxdeepin/deepin-desktop-base/archive/$pkgver.tar.gz"
        distribution.info
        deepin-deskto-base-la64.patch)
sha512sums=('ed9f3152e19f7c1de12b734f3db1698f7730d18663cdd6a91096d3b9d7fe17932f4efa163665468544db31de92e8757552b053b33e8f969c72e1e1192dfe2ee2'
            '27625e6d0786b8adacdb7c52806d4faa28d2ab6b319a593b3ea9bcb69f0cc18ea19b258d629e3a0069ef9a69503589b0285289caef39a1e85bbd99e915c7cd7d'
            'f79f5377f13e76ea812c822d9d6c41aa0faac16de1a0ddaa95b05673022fc5fe8f332f3bba6a99f6dfff4ffac6aa32d4bdd2ec44104fe1503de25cefa2709efe')

prepare() {
  cd "$pkgname-$pkgver"
  patch -p1 -i "$srcdir/deepin-deskto-base-la64.patch"
}

build() {
  cd $pkgname-$pkgver
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install

  install -Dm644 "$srcdir"/distribution.info -t "$pkgdir"/usr/share/deepin/

  # Remove Deepin distro's lsb-release
  rm "$pkgdir"/etc/lsb-release

  # Don't override systemd timeouts
  rm -r "$pkgdir"/etc/systemd

  # Make a symlink for deepin-version
  ln -s ../usr/lib/deepin/desktop-version "$pkgdir"/etc/deepin-version

  # Install os-version and rename to uos-version
  cp files/os-version-amd files/os-version
  install -Dm644 files/os-version "$pkgdir"/etc/uos-version

  # Remove apt-specific templates
  rm -r "$pkgdir"/usr/share/python-apt
}
